package com.neuedu.controller;

import com.neuedu.entity.UmsUser;
import com.neuedu.service.UmsUserService;
import com.neuedu.vo.ResultJson;
import io.minio.errors.*;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author 王禹
 * @since 2025-08-07
 */
@RestController
@RequestMapping("/umsUser")
public class UmsUserController {
    @Resource
    UmsUserService umsUserService;
    @GetMapping("/check")
    ResultJson<Boolean> check(String field, String value, Long id) {
        return ResultJson.success(umsUserService.check(field, value, id));
    }
    @PostMapping("/add")
    ResultJson<Boolean> add(UmsUser umsUser, MultipartFile file, String password) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        return ResultJson.success(umsUserService.add(umsUser, file, password), "注册用户成功");
    }

    ResultJson<String> login(String username, String password) {
        return ResultJson.success(umsUserService.login(username, password));
    }
    @GetMapping("/test")
    ResultJson<List<UmsUser>> test () {
        return ResultJson.success(umsUserService.list());
    }
    @GetMapping("/test2")
    ResultJson<String> test2() {
        return ResultJson.success("测试成功444555");
    }
}
